package TI;

import junit.framework.TestCase;

import org.junit.Test;

public class AddressTest extends TestCase {

	Address addressToTest;
	
	@Test
	public void testGivenAnAddressWhenAskedToStringShouldContainsAllTheParameters(){
		
		addressToTest = new Address("Roque Saenz Pena", 352, "Bernal", "B1876BXD", "Buenos Aires", "Argentina");
		String returnValue = addressToTest.toString();
		assertTrue(returnValue.contains("Roque Saenz Pena"));
		assertTrue(returnValue.contains("352"));
		assertTrue(returnValue.contains("B1876BXD"));
		assertTrue(returnValue.contains("Buenos Aires"));
		assertTrue(returnValue.contains("Argentina"));
	}
	
	@Test
	public void testGivenAnAddressWhenAskedIsEqualsAnotherAddressThatIsTheSameShouldReturnTrue(){
		addressToTest = new Address("Roque Saenz Pena", 352, "Bernal", "B1876BXD", "Buenos Aires", "Argentina");
		Address addressToCompare = new Address("Roque Saenz Pena", 352, "Bernal", "B1876BXD", "Buenos Aires", "Argentina");
		
		assertTrue(addressToTest.isEquals(addressToCompare));
	}
	
	@Test
	public void testGivenAnAddressWhenAskedIsEqualsAnotherAddressThatIsNotTheSameShouldReturnFalse(){
		addressToTest = new Address("Roque Saenz Pena", 352, "Bernal", "B1876BXD", "Buenos Aires", "Argentina");
		Address addressToCompare = new Address("Roque Saenz Pena", 354, "Bernal", "B1876BXD", "Buenos Aires", "Argentina");
		Address anotherAddressToCompare = new Address("Roque Saenz Pena", 352, "LaPlata", "B1876BXD", "Buenos Aires", "Argentina");
		Address justAnotherAddressToCompare = new Address("Rodriguez Pena", 352, "Bernal", "B1876BXD", "Buenos Aires", "Argentina");
		
		assertFalse(addressToTest.isEquals(addressToCompare));
		assertFalse(addressToTest.isEquals(anotherAddressToCompare));
		assertFalse(addressToTest.isEquals(justAnotherAddressToCompare));
	}
	
	@Test
	public void testGivenAnAddressWhithNegativeNumberWhenAskedToStringShouldContainsSN(){
		
		addressToTest = new Address(" ", -1, " ", " ", " ", " ");
		String returnValue = addressToTest.toString();
		assertTrue(returnValue.contains("s/n"));
	}
}
